let mask = null;
let view = null;
export default {
 
  viewHotFixInit() {
    if (!mask) {
      mask = new plus.nativeObj.View('viewHotFixMask', {
        bottom: '0',
        left: '0',
        right: '0',
        top: '0',
				color: '#fff',
        // position: 'dock'
      });
    }
 
    mask.drawRect({
      color: 'rgba(0, 0, 0, 0.5)'
      //color: 'rgba(255, 255, 255, 0.0)'// 有颜色
    });
		
    if (!view) {
      view = new plus.nativeObj.View('viewHotFixView', {
        top: '40%',
				left: '14%',
				right: '20%',
        width: '90%',
        height: '150px',
        position: 'dock',
				textAlign: "center"
      }, [
				// {
    //     tag: 'img',
    //     id: 'bgroundicon',
    //     position: {
    //       top: '0',
    //       left: '0',
    //       width: '100%',
    //       height: '100%'
    //     },
    //     src: '_www/static/updata/update-img.png'
    //   },
			{
        tag: 'font',
        id: 'icon',
        text: '恭喜你 发现新版本',
        position: {
          top: '16px',
          left: '20px',
          width: '90%',
          height: '30px',
 
        },
        textStyles: {
          align: 'left',
          color: '#ffffff',
          size: '16px'
        }
      }, 
      {
        tag: 'font',
        id: 'title',
        text: '正在为您 火速下载中.. .',
        position: {
          bottom: '40px',
					left: '5%',
          width: '80%',
          height: '40px',
					textAlign: 'left'
      
        },
        textStyles: {
          align: 'left',
          color: '#ff832a',
          weight:'bold',
          size: '14px'
        }
      },{
        tag: 'rect',
        id: 'processGB',
        position: {
          bottom: '40px',
          left: '5%',
          width: '80%',
          height: '9px',
        },
        rectStyles: {
          color: 'rgba(186, 186, 186, 1.0)',
          size: '100%',
          radius: '3px'
        }
      }, {
        tag: 'rect',
        id: 'processFR',
        position: {
          bottom: '40px',
          left: '0',
          width: '0',
          height: '9px',
        },
        rectStyles: {
          color: 'rgba(110, 166, 64, 1.0)',
          size: '100%',
          radius: '3px'
        }
      }, {
        tag: 'font',
        id: 'process',
        text: '0%',
        position: {
          bottom: '10px',
          left: '20px',
          width: '40px',
          height: '30px',
        },
        textStyles: {
          align: 'left',
          color: '#000000',
          size: '15px'
        }
      }])
    }

		try{
			mask.show()
			view.show()
			mask.addEventListener("click", () => {
						console.log('点击了按钮')
					}, false);
					
			}catch(e){
				console.log(e)
			}
		 
  },
  viewHotFixUpdate(progress) {
		if(!view)return;
    view.drawText(progress + '%', {
      bottom: '10px',
      left: (progress * 0.8+5) + '%',
      width: '40px',
      height: '30px',
    }, {
      align: 'left',
      color: '#000000',
      size: '15px'
    }, 'process')
 
 
    view.drawRect({
      color: 'rgba(110, 166, 64, 1.0)',
      size: '100%',
      radius: '3px'
    }, {
      bottom: '40px',
      left: '5%',
      width: (progress * 0.9) + '%',
      height: '9px',
    }, 'processFR')
  },
  viewHotFixHide() {
    if (view) {
      view.hide()
    }
    if (mask) {
      mask.hide()
    }
  }
}